<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="jquery-1.7.2.js"></script>
<script type="text/javascript">
var f= opener.document;
	$(document).ready(function() {		

		$("#ok").click(function(){			
			
			if($(":input:radio:[name=credit]:checked").length>0){			
				var method= $(":input:radio:[name=credit]:checked").val();
				var flag= window.confirm("예매하시겠습니까?");
				if(flag!=true){
					return false;
				}else{
				
				 	$.ajax({
						type:"post",
						url:"reservation.do",
						data:"command=reservationOK&timetable_no=${requestScope.info.timetable_no}&pMethod="+method+"&price=${requestScope.info.AllCost}&ticketCount=${requestScope.info.ticketCount}&seat=${requestScope.info.seat}",
						success:function(){
							alert("예매완료");
							opener.location="reservation.do?command=res_confirm";
							self.close();							
						},
						error:function(){
							alert("예매 실패..!!");
						}
						
					});					
				}
			}else{
				alert("결제 방식을 선택하세요!!");
				return false;
			}
		});//click
		
				
		$("#cancle").click(function(){
			var flag= window.confirm("취소하시겠습니까?");
			if(flag!=true){
				return false;
			}else{
				$("#ticketing",opener.document).show();
				$("#backBtn",opener.document).show();
				self.close();					
			}				
		});	
		// x로 닫기
		$(window).unload(function() { 
			$("#ticketing",opener.document).show();
			$("#backBtn",opener.document).show();
			self.close();	
		});
	});//ready
</script>
</head>
<body>

	<!-- 신용카드 클릭 하면 카드 번호 입력창으로... ajax -->
	
	<table border="1"  cellspacing="0" align="center">	
	<c:forEach items="${requestScope.info.tt_info}" var="info">
		<tr>
			<td>영 화</td>
			<td>${info.MOVIE_TITLE}</td>
		</tr>
		<tr>
			<td>상영 날짜</td>
			<td>${info.STARTING_TIME}</td>
		</tr>
		<tr>
			<td>상영관정보</td>
			<td>${info.THEATER},${info.PLAY_ROOM_NO}관</td>
		</tr>
			</c:forEach>
		<tr>
			<td>좌석 정보</td>
			<td>${requestScope.info.seat}</td>
		</tr>
		<tr>
			<td>결제 금액</td>
			<td>${requestScope.info.AllCost }</td>
		</tr>
		
		<tr align="center">
		<td colspan="2" align="center">
			<c:forEach items="${requestScope.info.pMethod}" var="method">
				<input type="radio" name="credit"
					value="${method.payment_no }"> ${method.payment }
			</c:forEach>
			</td>
		</tr>
		<tr align="center">
			<td colspan="2">
				<input type="button" value="결제" id="ok">
				<input	type="button" value="취소" id="cancle">
			</td>
		</tr>
	</table>

</body>
</html>